package standalone;

import java.util.HashMap;

public class Category {
	//pierwszy Integer to numer kolumny, drugi to numer danego zasobu, trzeci liczba wystapien 
	private HashMap<Integer, HashMap<Integer,Integer>> ilosc = new HashMap<>();
	//ten counter policzy ilosc wystapien klasy dla danego reusorce
	private int counter;
	
	//indeks 0 to ACTION i 1 to rRESOURCE to nas nie interesuje
	public void saveRow(String[] line){
		Integer val;
		Integer zasob;
		HashMap<Integer,Integer> entity;
		for(int i = 2; i< line.length; i++){
			entity = ilosc.get(i);
			if(entity == null){
				entity = new HashMap<>();
				ilosc.put(i, entity);
			}
			zasob = Integer.valueOf(line[i]);
			
			val = entity.get(zasob);
			if(val == null){
				val = 1;
			}else{
				val++;
			}
			entity.put(zasob, val);
		}
		counter++;
	}
	
	public int getCount(int indeks, int resourceNumber){
		 Integer val;
		val = ilosc.get(indeks).get(resourceNumber);
		if(val == null)
			val = 0;
		return val;
	}

	public int getCounter() {
		return counter;
	}
	
}
